namespace Blogs.ModelDB.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class blogs : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.BlogComment",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Content = c.String(),
                        CommentSort = c.String(),
                        CommentID = c.Int(nullable: false),
                        ContentLevy = c.String(),
                        IsInitial = c.Boolean(),
                        ReplyUserID = c.Int(),
                        ReplyUserName = c.String(),
                        AnonymousName = c.String(),
                        CommentIP = c.String(),
                        CreationTime = c.DateTime(),
                        LastModifiedTime = c.DateTime(),
                        IsDelte = c.Boolean(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        BlogInfoId = c.Int(nullable: false),
                        BlogUserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BlogInfo", t => t.BlogInfoId)
                .ForeignKey("dbo.BlogUser", t => t.BlogUserId)
                .Index(t => t.BlogInfoId)
                .Index(t => t.BlogUserId);
            
            CreateTable(
                "dbo.BlogInfo",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        BlogContent = c.String(),
                        BlogRemarks = c.String(),
                        BlogTitle = c.String(),
                        BlogUrl = c.String(),
                        IsForwarding = c.Boolean(),
                        BlogCreateTime = c.DateTime(),
                        BlogUpTime = c.DateTime(),
                        BlogReadNum = c.Int(),
                        BlogForUrl = c.String(),
                        IsShowHome = c.Boolean(),
                        IsShowMyHome = c.Boolean(),
                        BlogCommentNum = c.Int(),
                        CreationTime = c.DateTime(),
                        LastModifiedTime = c.DateTime(),
                        IsDelte = c.Boolean(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        BlogUserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BlogUser", t => t.BlogUserId)
                .Index(t => t.BlogUserId);
            
            CreateTable(
                "dbo.BlogReadInfo",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MD5 = c.String(),
                        LastTime = c.DateTime(nullable: false),
                        CreationTime = c.DateTime(),
                        LastModifiedTime = c.DateTime(),
                        IsDelte = c.Boolean(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        BlogInfoId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BlogInfo", t => t.BlogInfoId)
                .Index(t => t.BlogInfoId);
            
            CreateTable(
                "dbo.BlogTag",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        TagName = c.String(),
                        TagRemarks = c.String(),
                        CreationTime = c.DateTime(),
                        LastModifiedTime = c.DateTime(),
                        IsDelte = c.Boolean(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        BlogUserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BlogUser", t => t.BlogUserId)
                .Index(t => t.BlogUserId);
            
            CreateTable(
                "dbo.BlogUser",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserName = c.String(),
                        UserPass = c.String(),
                        UserNickname = c.String(),
                        UserMail = c.String(),
                        IsLock = c.Boolean(nullable: false),
                        UserImage = c.String(),
                        CreationTime = c.DateTime(),
                        LastModifiedTime = c.DateTime(),
                        IsDelte = c.Boolean(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.BlogType",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        TypeName = c.String(),
                        TypeRemarks = c.String(),
                        CreationTime = c.DateTime(),
                        LastModifiedTime = c.DateTime(),
                        IsDelte = c.Boolean(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        BlogUserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BlogUser", t => t.BlogUserId)
                .Index(t => t.BlogUserId);
            
            CreateTable(
                "dbo.BlogUserInfo",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Age = c.String(),
                        Sex = c.String(),
                        Hobby = c.String(),
                        Profile = c.String(),
                        BlogLastUpTime = c.DateTime(),
                        BlogUpNum = c.Int(nullable: false),
                        IsDisCSS = c.Boolean(),
                        IsShowCSS = c.Boolean(),
                        IsShowHTML = c.Boolean(),
                        IsShowJS = c.Boolean(),
                        IsShowMCSS = c.Boolean(),
                        IsDisMCSS = c.Boolean(),
                        BlogTheme = c.String(),
                        OAuthName = c.String(),
                        OAuthId = c.String(),
                        CreationTime = c.DateTime(),
                        LastModifiedTime = c.DateTime(),
                        IsDelte = c.Boolean(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        BlogUserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BlogUser", t => t.BlogUserId)
                .Index(t => t.BlogUserId);
            
            CreateTable(
                "dbo.BlogInfo_BlogTag",
                c => new
                    {
                        BlogInfo_Id = c.Int(nullable: false),
                        BlogTag_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.BlogInfo_Id, t.BlogTag_Id })
                .ForeignKey("dbo.BlogInfo", t => t.BlogInfo_Id, cascadeDelete: true)
                .ForeignKey("dbo.BlogTag", t => t.BlogTag_Id, cascadeDelete: true)
                .Index(t => t.BlogInfo_Id)
                .Index(t => t.BlogTag_Id);
            
            CreateTable(
                "dbo.BlogInfo_BlogType",
                c => new
                    {
                        BlogInfo_Id = c.Int(nullable: false),
                        BlogType_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.BlogInfo_Id, t.BlogType_Id })
                .ForeignKey("dbo.BlogInfo", t => t.BlogInfo_Id, cascadeDelete: true)
                .ForeignKey("dbo.BlogType", t => t.BlogType_Id, cascadeDelete: true)
                .Index(t => t.BlogInfo_Id)
                .Index(t => t.BlogType_Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.BlogInfo_BlogType", "BlogType_Id", "dbo.BlogType");
            DropForeignKey("dbo.BlogInfo_BlogType", "BlogInfo_Id", "dbo.BlogInfo");
            DropForeignKey("dbo.BlogInfo_BlogTag", "BlogTag_Id", "dbo.BlogTag");
            DropForeignKey("dbo.BlogInfo_BlogTag", "BlogInfo_Id", "dbo.BlogInfo");
            DropForeignKey("dbo.BlogUserInfo", "BlogUserId", "dbo.BlogUser");
            DropForeignKey("dbo.BlogType", "BlogUserId", "dbo.BlogUser");
            DropForeignKey("dbo.BlogTag", "BlogUserId", "dbo.BlogUser");
            DropForeignKey("dbo.BlogInfo", "BlogUserId", "dbo.BlogUser");
            DropForeignKey("dbo.BlogComment", "BlogUserId", "dbo.BlogUser");
            DropForeignKey("dbo.BlogReadInfo", "BlogInfoId", "dbo.BlogInfo");
            DropForeignKey("dbo.BlogComment", "BlogInfoId", "dbo.BlogInfo");
            DropIndex("dbo.BlogInfo_BlogType", new[] { "BlogType_Id" });
            DropIndex("dbo.BlogInfo_BlogType", new[] { "BlogInfo_Id" });
            DropIndex("dbo.BlogInfo_BlogTag", new[] { "BlogTag_Id" });
            DropIndex("dbo.BlogInfo_BlogTag", new[] { "BlogInfo_Id" });
            DropIndex("dbo.BlogUserInfo", new[] { "BlogUserId" });
            DropIndex("dbo.BlogType", new[] { "BlogUserId" });
            DropIndex("dbo.BlogTag", new[] { "BlogUserId" });
            DropIndex("dbo.BlogInfo", new[] { "BlogUserId" });
            DropIndex("dbo.BlogComment", new[] { "BlogUserId" });
            DropIndex("dbo.BlogReadInfo", new[] { "BlogInfoId" });
            DropIndex("dbo.BlogComment", new[] { "BlogInfoId" });
            DropTable("dbo.BlogInfo_BlogType");
            DropTable("dbo.BlogInfo_BlogTag");
            DropTable("dbo.BlogUserInfo");
            DropTable("dbo.BlogType");
            DropTable("dbo.BlogUser");
            DropTable("dbo.BlogTag");
            DropTable("dbo.BlogReadInfo");
            DropTable("dbo.BlogInfo");
            DropTable("dbo.BlogComment");
        }
    }
}
